using System.Drawing;
using System.Windows.Forms;
using CartoGraphic.Model2;

namespace CartoGraphic.MyTool
{
	internal class ToolLine : ToolObj
	{
		public ToolLine()
		{
            Cursor = Cursors.Default;
		}

		public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
		{
			Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            AddNewObject(drawArea, new LineObj(p.X, p.Y, p.X + 1, p.Y + 1));
		}

		public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
		{
			drawArea.Cursor = Cursor;

			if (e.Button ==
			    MouseButtons.Left)
			{
				Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));
				string al = drawArea.TheLayers.ActiveLayerIndex;
				drawArea.TheLayers[al].Graphics[0].MoveHandleTo(point, 2);
				drawArea.Refresh();
			}
		}
	}
}